﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace DAO
{
    public class ThamSoDAO : DataAccess
    {
        public ThamSo CreateObj(DataRow row)
        {
            ThamSo obj = new ThamSo();
            obj.MaTS = Utils.ToStr(row["MaTS"]);
            obj.TenTS = Utils.ToStr(row["TenTS"]);
            obj.GiaTri = Utils.ToFloat(row["GiaTri"]);
            return obj;
        }
        public List<ThamSo> GetList()
        {
            DataTable tb = GetData("EXEC GetData ?", "@TableNameX", "ThamSo", OleDbType.VarChar);
            List<ThamSo> Lst = new List<ThamSo>();
            for (int i = 0; i < tb.Rows.Count; i++)
                Lst.Add(CreateObj(tb.Rows[i]));
            return Lst;
        }
        public bool Update(ThamSo obj)
        {
            return UpdateDeleteData("EXEC UpdateThamSo ?, ?, ?", CommandType.Text,
                                    "@MaTS", obj.MaTS, OleDbType.VarChar,
                                    "@TenTS", obj.TenTS, OleDbType.VarWChar,
                                    "@GiaTri", obj.GiaTri, OleDbType.Double);
        }
    }
}
